﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using YWTSSys.BLL;
using YWTSSys.Library;
using YWTSSys.Model;

namespace YWTSSys.Web.MachineSys.YWTSWeb.yw
{
    public partial class MyCustomerMasterList : PageBase
    {
        protected override Permission[] PowerKey
        {
            get
            {
                return new Permission[] { Permission.新增 };
            }
        }
        protected override string DWZRef
        {
            get
            {
                return "MyCustomerMasterList";
            }
        }

        #region 属性 (查询条件)


        protected string sqlvalue
        {
            get
            {
                return GetRequestValue<string>("sqlvalue", "");

            }
        }


        /// <summary>
        /// 当前排序字段
        /// </summary>
        protected override string orderField
        {
            get
            {
                return string.IsNullOrEmpty(base.orderField) ? "电话拔打状态" : base.orderField;
            }
        }
        /// <summary>
        /// 当前排序方式
        /// </summary>
        protected override string orderDirection
        {
            get
            {
                if (orderField == "电话拔打状态")
                    return "ASC";
                return string.IsNullOrEmpty(base.orderDirection) ? "ASC" : base.orderDirection;
            }
        }
        #endregion



        protected void Page_Load(object sender, EventArgs e)
        {
            DataBind();
            this.AddLog(Permission.查看, GetSql());
        }

        protected void DataBind()
        {

            this.rpMenu.DataSource = CustomerController.GetMyCustomerPagination(base.User.UserId, GetSql(),  pageNum, numPerPage,SQLSort,ref TotalCount);
            this.rpMenu.DataBind();
        }
        protected string GetSql()
        {
            //   string wheresql = string.Format(" 客户名称 like '%{0}%' or 手机号码 like '%{0}%' or 会员卡号 like '%{0}%' ", sqlvalue);

            string ItemCodeSQL = "";
            if (!string.IsNullOrEmpty(sqlvalue))
            {
                ItemCodeSQL = string.Format(" (客户名称 like '%{0}%' or 手机号码 like '%{0}%' or 会员卡号 like '%{0}%' ) ", sqlvalue);

            }
            
            return ItemCodeSQL;
        }
    }
}